cmake_minimum_required(VERSION 3.18.1)


project("rtmppusher")


include_directories(${CMAKE_SOURCE_DIR}/myLibs/include)


add_library(faac STATIC IMPORTED)
set_target_properties(faac PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/myLibs/${CMAKE_ANDROID_ARCH_ABI}/libfaac.so)

add_library(x264 STATIC IMPORTED)
set_target_properties(x264 PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/myLibs/${CMAKE_ANDROID_ARCH_ABI}/libx264.a)

add_library(avfilter SHARED IMPORTED)
set_target_properties(avfilter PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/myLibs/${CMAKE_ANDROID_ARCH_ABI}/libavfilter.so)

add_library(avformat SHARED IMPORTED)
set_target_properties(avformat PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/myLibs/${CMAKE_ANDROID_ARCH_ABI}/libavformat.so)

add_library(avcodec SHARED IMPORTED)
set_target_properties(avcodec PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/myLibs/${CMAKE_ANDROID_ARCH_ABI}/libavcodec.so)

add_library(avutil SHARED IMPORTED)
set_target_properties(avutil PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/myLibs/${CMAKE_ANDROID_ARCH_ABI}/libavutil.so)

add_library(swresample SHARED IMPORTED)
set_target_properties(swresample PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/myLibs/${CMAKE_ANDROID_ARCH_ABI}/libswresample.so)

add_library(swscale SHARED IMPORTED)
set_target_properties(swscale PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/myLibs/${CMAKE_ANDROID_ARCH_ABI}/libswscale.so)

add_library(rtmp STATIC IMPORTED)
set_target_properties(rtmp PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/myLibs/${CMAKE_ANDROID_ARCH_ABI}/librtmp.a)


add_library(
        rtmppusher
        SHARED
        native-lib.cpp
        base/Bases.h
        base/Bases.cpp
        base/JavaCaller.h
        base/JavaCaller.cpp
        commons/JniMacro.h
        commons/JniMacro.cpp
        commons/QueueThread.h
        commons/SafeQueue.h
        AudioChannel.h
        AudioChannel.cpp
        VideoChannel.h
        VideoChannel.cpp
)


find_library(
        log-lib
        log)


target_link_libraries(
        rtmppusher
        faac x264 avfilter avformat avcodec avutil swresample swscale rtmp z OpenSLES android
        ${log-lib})